package com.no1ikun.util;

import javax.swing.*;
import java.awt.*;

//封装一个JLabel可以方便以后可以灵活的使用
public class MyJLabel extends JLabel {
    private String text;
    private int width;
    private int height;
    private int x;
    private int y;
    private String fontName;//字体
    private int fontStyle;//字体
    private int fontSize;//字体的大小
    private Color fontColor;//字体的颜色

    public MyJLabel(String text, int width, int height, int x, int y, String fontName,int fontStyle, int fontSize, Color fontColor) {
        this.text = text;
        this.width = width;
        this.height = height;
        this.x = x;
        this.y = y;
        this.fontName = fontName;
        this.fontStyle = fontStyle;
        this.fontSize = fontSize;
        this.fontColor = fontColor;
        init();
    }

    private void init() {
        //设置文字
        this.setText(text);
        //设置显示的位置和宽高
        //设置位置
        this.setBounds(x, y, width, height);
        Font font = new Font(fontName, fontStyle, fontSize);
        this.setFont(font);
        //设置字体的颜色
        this.setForeground(fontColor);
        this.setVisible(true);

    }
}
